#include "Session.h"

Session::Session(tcp::socket *socket, std::size_t ID)
:mTCPSocket(socket)
,isWrittingBuffer(false)
,IDSession(ID)
,isActive(true)
,mEndPoint(NULL)
{

};

Session::Session(std::size_t ID)
:mTCPSocket(NULL)
,isWrittingBuffer(false)
,IDSession(ID)
,isActive(true)
,mEndPoint(NULL)
{

};

void Session::Reset(tcp::socket* socket)
{
    delete mTCPSocket;
    mTCPSocket = socket;
    isActive = true;
}
void Session::Reset(udp::socket* socket)
{
    isActive = true;
}
void Session::GetSocket(tcp::socket* socket)
{
    socket = mTCPSocket;
}
tcp::socket* Session::GetTCPSocket()
{
    return mTCPSocket;
}

udp::endpoint* Session::GetEndPoint()
{
    return mEndPoint;
}
void Session::SetEndPoint(const udp::endpoint& endpoint)
{
    if(mEndPoint!=NULL)
        delete mEndPoint;
    mEndPoint = new udp::endpoint(endpoint);
}
std::size_t Session::GetID() const
{
    return IDSession;
}
boost::array<char*, 1>& Session::GetBuffer()
{
    return mBuffer;
}
void Session::SetBuffer(const boost::array<char*, 1>& buffer)
{
    mBuffer = buffer;
}
boost::system::error_code Session::GetErrorCode() const
{
    return errorCode;
}
void Session::SetErrorCode(const boost::system::error_code& error)
{
    errorCode = error;
}
std::size_t Session::GetBytesSize() const
{
    return bytes_transferred;
}
void Session::SetBytesSize(std::size_t size)
{
    bytes_transferred = size;
}

bool Session::GetActive() const
{
    return isActive;
}
void Session::SetActive(bool active)
{
    isActive = active;
}
